function  Food(el){
        this.el = el
        this.len = 20
        this.foodobj = null
        this.foodx = 0
        this.foody = 0
}
// 创造食物
Food.prototype.create = function(){
        let divobj = document.createElement('div')
       
        divobj.style.width = this.len+'px'
        divobj.style.height = this.len+'px'
        divobj.style.background = 'green'    
        divobj.style.position= 'absolute'    
        this.el.appendChild(divobj)
        this.foodobj =divobj
}
// 让食物随机移动
Food.prototype.move=function(){
    let foodxmaxnum =  this.el.clientWidth/this.len-1
    let foodymaxnum =  this.el.clientHeight/this.len-1
    this.foodx= Math.floor(Math.random() * (foodxmaxnum -0+1)+0)* this.len
    this.foody = Math.floor(Math.random() * (foodymaxnum -0+1)+0)* this.len
    
  
  
    this.foodobj.style.left = this.foodx +'px'
    this.foodobj.style.top =  this.foody +'px'

}
